package com.appsys.uitl;
import java.io.IOException;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class MybaitsUitl {
	private static final String MYBATIS_CONFIG_XML="MyBatis-Configuration.xml";
	private static SqlSessionFactory factory=null;
	
	static{
		SqlSessionFactoryBuilder builder=new SqlSessionFactoryBuilder();
		try {
			factory = builder.build(Resources.getResourceAsStream(MYBATIS_CONFIG_XML));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
	//SqlSessionFactory
	public static SqlSession getSession(){
		
		return factory.openSession();
	}
	public static void closeSession(SqlSession session){
		session.close();
	}
	public static SqlSession getSession(boolean fx){
		return factory.openSession(fx);
	}
}	
